/**
 * 管理初始化
 */
var TOrderFeeLog = {
    id: "TOrderFeeLogTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
TOrderFeeLog.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '订单费用ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
            {title: '订单ID', field: 'orderId', visible: true, align: 'center', valign: 'middle'},
            {title: '企业ID', field: 'dotId', visible: true, align: 'center', valign: 'middle'},
            {title: '部门ID', field: 'detpId', visible: true, align: 'center', valign: 'middle'},
            {title: '对应的费用ID', field: 'feeId', visible: true, align: 'center', valign: 'middle'},
            {title: '费用金额', field: 'money', visible: true, align: 'center', valign: 'middle'},
            {title: '收入或者支出 0-收入 1-支出', field: 'feeIncome', visible: true, align: 'center', valign: 'middle'},
            {title: '付款方式 0-现金  1-支付宝 2-微信 3-银行转账 4-其他', field: 'payMode', visible: true, align: 'center', valign: 'middle'},
            {title: '0 未结算 1 已结算 2 坏账 3 清账', field: 'auditStatus', visible: true, align: 'center', valign: 'middle'},
            {title: '是否原始导入 0 是 1否', field: 'isOriginal', visible: true, align: 'center', valign: 'middle'},
            {title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
            {title: '创建该费用名称的用户ID', field: 'createUserId', visible: true, align: 'center', valign: 'middle'},
            {title: '0 正常 1 坏账', field: 'isBadDebt', visible: true, align: 'center', valign: 'middle'},
            {title: '结算方式 0 当场结算 1 月结', field: 'settlementType', visible: true, align: 'center', valign: 'middle'},
            {title: '申请人', field: 'applicant', visible: true, align: 'center', valign: 'middle'},
            {title: '', field: 'logNo', visible: true, align: 'center', valign: 'middle'},
            {title: '', field: 'remark', visible: true, align: 'center', valign: 'middle'},
            {title: '操作人', field: 'opUserId', visible: true, align: 'center', valign: 'middle'},
            {title: '0 临时 1 正式', field: 'status', visible: true, align: 'center', valign: 'middle'},
            {title: '', field: 'orderFeeId', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
TOrderFeeLog.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        TOrderFeeLog.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加
 */
TOrderFeeLog.openAddTOrderFeeLog = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tOrderFeeLog/tOrderFeeLog_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看详情
 */
TOrderFeeLog.openTOrderFeeLogDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tOrderFeeLog/tOrderFeeLog_update/' + TOrderFeeLog.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除
 */
TOrderFeeLog.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/tOrderFeeLog/delete", function (data) {
            Feng.success("删除成功!");
            TOrderFeeLog.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("tOrderFeeLogId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询列表
 */
TOrderFeeLog.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    TOrderFeeLog.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = TOrderFeeLog.initColumn();
    var table = new BSTable(TOrderFeeLog.id, "/tOrderFeeLog/list", defaultColunms);
    table.setPaginationType("client");
    TOrderFeeLog.table = table.init();
});
